import React from 'react';
import AvatarSelector from '../../component/avatarSelector/avatarSelector'
import { NavBar,InputItem,TextareaItem,Button,WhiteSpace } from 'antd-mobile';
import { Redirect } from 'react-router-dom';
import { connect } from 'react-redux';
import { update } from '../../redux/user.redux.js';

@connect(
state => state.user,
{update}
)
class BossInfo extends React.Component{
	constructor(props) {
	    super(props);
		this.state = {
			title:'',
			company:'',
			money:'',
			desc:''
			
		}
	}
	handleChange(key,value){
		this.setState({
			[key]:value
		});
	}
	
	handleUpdate(){
		this.props.update(this.state);
	}
	
	render(){
		const curPath = this.props.location.pathname;
		const redirect = this.props.redirectTo;
		return (
			<div>
				{redirect && curPath !== redirect ? <Redirect to={this.props.redirectTo}></Redirect> : null}
				<NavBar mode="dark">boss信息完善页面</NavBar>
				<AvatarSelector selectAvatar={(text) => {
					this.setState({
						avatar:text
					})
				}}></AvatarSelector>
				<WhiteSpace />
				<InputItem onChange={(v) => {this.handleChange('title',v)}}>
					招聘职位
				</InputItem>
				<InputItem onChange={(v) => {this.handleChange('company',v)}}>
					公司名称
				</InputItem>
				<InputItem onChange={(v) => {this.handleChange('money',v)}}>
					职位薪资
				</InputItem>
				<TextareaItem 
					onChange={(v) => {this.handleChange('desc',v)}}
					title='职位要求'
					rows={3}
					autoHeight
				>
				</TextareaItem>
				<Button type="primary" onClick={this.handleUpdate.bind(this)}>提交资料</Button>
			</div>
		)
	}
}

export default BossInfo